package com.baor.dao;

import com.baor.domain.CouponVo;
import com.baor.domain.MoneyVo;
import com.baor.domain.UserVo;
import com.github.yulichang.base.mapper.MPJJoinMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
public interface VipDao extends MPJJoinMapper<UserVo> {


    //登录查询
    @Select("SELECT\n" +
            "        user_id,\n" +
            "        user_account,\n" +
            "        user_name,\n" +
            "        user_tel,\n" +
            "        user_image,\n" +
            "        create_time,\n" +
            "        user_last_time,\n" +
            "        user_birthday,\n" +
            "        wx_openid,\n" +
            "        user_status,\n" +
            "        user_can_be,\n" +
            "        user_cant_be,\n" +
            "        user_score,\n" +
            "        user_total_score,\n" +
            "        user_canuse_money,\n" +
            "        user_total_money,\n" +
            "        user_distribution_money,\n" +
            "        user_total_distribution,\n" +
            "        site_id,\n" +
            "        (SELECT user_tag_name FROM t_user_tag b WHERE a.user_tag_id = b.user_tag_id) AS user_tag_id,\n" +
            "        (SELECT order_source_name FROM t_order_source_field c WHERE a.order_source_id = c.order_source_id) AS\n" +
            "        order_source_id,\n" +
            "        CASE\n" +
            "        WHEN user_sex = 1 THEN '男'\n" +
            "        WHEN user_sex = 2 THEN '女'\n" +
            "        END AS user_sex\n" +
            "        FROM t_user a where user_tel = #{userTel} and user_password = #{userPassword}")
    UserVo SelectUserList(UserVo userVo);

    @Select("select * from t_user where user_tel = #{userTel}")
    List<UserVo> check(String userTel);
    //会员列表
    List<UserVo> userList(Map<String, Object> params);

    //分页
    int pageCount(Map<String, Object> params);

    //根据ID查询用户信息
    UserVo getUserInfo(Integer userId);

    //用户余额查询列表
    List<MoneyVo> userBalanceList(Map<String, Object> params);

    //计算会员余额总 余额、可提现余额、不可体现余额
    UserVo calculateBalance();

    List<MoneyVo> vipCommissionList(Map<String, Object> params);

    @Update("update t_user set user_superior = #{superiorId} where user_id = #{userId} ")
    Integer updateSuperior(Integer userId, Integer superiorId);
}
